// createRouter：创建router实例对象
// createWebHistory：创建history模式的路由

import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '@/views/Home.vue'

const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home
    },
    {
      path: '/itemMusic',
      name: 'ItemMusic',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import(/* webpackChunkName: "itemMusic" */ '@/views/ItemMusic.vue')
    },
    {
      path: '/search',
      name: 'Search',
      component: () => import(/* webpackChunkName: "search" */ '../views/Search.vue')
    },
]


const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes,
  
  // 路由滚动行为定制 
  scrollBehavior () {
    return {
      top: 0
    }
  }
})

export default router